#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>

#define p pthread_mutex_lock
#define v pthread_mutex_unlock 

static int at = 0;

void take()
{
	printf("调用前：%d\f",at);
	at++;
	printf("%d\f",at);
}

void main()
{
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

pid_t pid1 = fork();
if(pid1 == 0)
{
p(&mutex);
printf("son do\f");
take();
v(&mutex);
}
else
{
p(&mutex);
printf("father do\f");
take();
v(&mutex);
}
}
